﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Windows.Forms;

namespace HslCommunication.Controls
{
	/// <summary>
	/// 一个自定义的按钮控件
	/// </summary>
	// Token: 0x0200016F RID: 367
	[DefaultEvent("Click")]
	public class UserButton : UserControl
	{
		/// <summary>
		/// 实例化一个按钮对象
		/// </summary>
		// Token: 0x06001E24 RID: 7716 RVA: 0x00090F20 File Offset: 0x0008F120
		public UserButton()
		{
			this.InitializeComponent();
		}

		// Token: 0x06001E25 RID: 7717 RVA: 0x00090FC0 File Offset: 0x0008F1C0
		private void UserButton_Load(object sender, EventArgs e)
		{
			this.sf = new StringFormat();
			this.sf.Alignment = StringAlignment.Center;
			this.sf.LineAlignment = StringAlignment.Center;
			base.SizeChanged += this.UserButton_SizeChanged;
			this.Font = new Font("微软雅黑", this.Font.Size, this.Font.Style);
			base.MouseEnter += this.UserButton_MouseEnter;
			base.MouseLeave += this.UserButton_MouseLeave;
			base.MouseDown += this.UserButton_MouseDown;
			base.MouseUp += this.UserButton_MouseUp;
			base.SetStyle(ControlStyles.ResizeRedraw, true);
			base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
			base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
		}

		// Token: 0x06001E26 RID: 7718 RVA: 0x000910A0 File Offset: 0x0008F2A0
		private void UserButton_SizeChanged(object sender, EventArgs e)
		{
			bool flag = base.Width > 1;
			if (flag)
			{
				base.Invalidate();
			}
		}

		/// <summary>
		/// 设置或获取显示的文本
		/// </summary>
		// Token: 0x17000625 RID: 1573
		// (get) Token: 0x06001E27 RID: 7719 RVA: 0x000910C4 File Offset: 0x0008F2C4
		// (set) Token: 0x06001E28 RID: 7720 RVA: 0x000910DC File Offset: 0x0008F2DC
		[Category("外观")]
		[DefaultValue("button")]
		[Description("用来设置显示的文本信息")]
		public string UIText
		{
			get
			{
				return this._text;
			}
			set
			{
				this._text = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 设置或获取显示文本的颜色
		/// </summary>
		// Token: 0x17000626 RID: 1574
		// (get) Token: 0x06001E29 RID: 7721 RVA: 0x000910ED File Offset: 0x0008F2ED
		// (set) Token: 0x06001E2A RID: 7722 RVA: 0x000910F5 File Offset: 0x0008F2F5
		[Category("外观")]
		[DefaultValue(typeof(Color), "Black")]
		[Description("用来设置显示的文本的颜色")]
		public Color TextColor { get; set; } = Color.Black;

		/// <summary>
		/// 设置按钮的圆角
		/// </summary>
		// Token: 0x17000627 RID: 1575
		// (get) Token: 0x06001E2B RID: 7723 RVA: 0x00091100 File Offset: 0x0008F300
		// (set) Token: 0x06001E2C RID: 7724 RVA: 0x00091118 File Offset: 0x0008F318
		[Category("外观")]
		[DefaultValue(3)]
		[Description("按钮框的圆角属性")]
		public int CornerRadius
		{
			get
			{
				return this.RoundCorner;
			}
			set
			{
				this.RoundCorner = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 用来设置按钮的选中状态
		/// </summary>
		// Token: 0x17000628 RID: 1576
		// (get) Token: 0x06001E2D RID: 7725 RVA: 0x0009112C File Offset: 0x0008F32C
		// (set) Token: 0x06001E2E RID: 7726 RVA: 0x00091144 File Offset: 0x0008F344
		[Category("外观")]
		[DefaultValue(false)]
		[Description("指示按钮的选中状态")]
		public bool Selected
		{
			get
			{
				return this.m_Selected;
			}
			set
			{
				this.m_Selected = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 已经弃用
		/// </summary>
		// Token: 0x17000629 RID: 1577
		// (get) Token: 0x06001E2F RID: 7727 RVA: 0x00091158 File Offset: 0x0008F358
		// (set) Token: 0x06001E30 RID: 7728 RVA: 0x00091170 File Offset: 0x0008F370
		[Browsable(false)]
		public override Color ForeColor
		{
			get
			{
				return base.ForeColor;
			}
			set
			{
				base.ForeColor = value;
			}
		}

		/// <summary>
		/// 已经弃用
		/// </summary>
		// Token: 0x1700062A RID: 1578
		// (get) Token: 0x06001E31 RID: 7729 RVA: 0x0009117C File Offset: 0x0008F37C
		// (set) Token: 0x06001E32 RID: 7730 RVA: 0x00091194 File Offset: 0x0008F394
		[Browsable(false)]
		public override string Text
		{
			get
			{
				return base.Text;
			}
			set
			{
				base.Text = value;
			}
		}

		/// <summary>
		/// 按钮的背景色
		/// </summary>
		// Token: 0x1700062B RID: 1579
		// (get) Token: 0x06001E33 RID: 7731 RVA: 0x000911A0 File Offset: 0x0008F3A0
		// (set) Token: 0x06001E34 RID: 7732 RVA: 0x000911B8 File Offset: 0x0008F3B8
		[Category("外观")]
		[DefaultValue(typeof(Color), "Lavender")]
		[Description("按钮的背景色")]
		public Color OriginalColor
		{
			get
			{
				return this.m_backcor;
			}
			set
			{
				this.m_backcor = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 按钮的背景色
		/// </summary>
		// Token: 0x1700062C RID: 1580
		// (get) Token: 0x06001E35 RID: 7733 RVA: 0x000911CC File Offset: 0x0008F3CC
		// (set) Token: 0x06001E36 RID: 7734 RVA: 0x000911E4 File Offset: 0x0008F3E4
		[Category("外观")]
		[Description("按钮的活动色")]
		public Color EnableColor
		{
			get
			{
				return this.m_enablecolor;
			}
			set
			{
				this.m_enablecolor = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 鼠标挪动时的活动颜色
		/// </summary>
		// Token: 0x1700062D RID: 1581
		// (get) Token: 0x06001E37 RID: 7735 RVA: 0x000911F8 File Offset: 0x0008F3F8
		// (set) Token: 0x06001E38 RID: 7736 RVA: 0x00091210 File Offset: 0x0008F410
		[Category("外观")]
		[DefaultValue(typeof(Color), "AliceBlue")]
		[Description("按钮的活动色")]
		public Color ActiveColor
		{
			get
			{
				return this.m_active;
			}
			set
			{
				this.m_active = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 设置按钮的边框是否可见
		/// </summary>
		// Token: 0x1700062E RID: 1582
		// (get) Token: 0x06001E39 RID: 7737 RVA: 0x00091224 File Offset: 0x0008F424
		// (set) Token: 0x06001E3A RID: 7738 RVA: 0x0009123C File Offset: 0x0008F43C
		[Category("外观")]
		[Browsable(true)]
		[DefaultValue(true)]
		[Description("指示按钮是否存在边框")]
		public bool BorderVisiable
		{
			get
			{
				return this.m_BorderVisiable;
			}
			set
			{
				this.m_BorderVisiable = value;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 存放用户需要保存的一些额外的信息
		/// </summary>
		// Token: 0x1700062F RID: 1583
		// (get) Token: 0x06001E3B RID: 7739 RVA: 0x0009124D File Offset: 0x0008F44D
		// (set) Token: 0x06001E3C RID: 7740 RVA: 0x00091255 File Offset: 0x0008F455
		[Browsable(false)]
		public string CustomerInformation { get; set; } = "";

		// Token: 0x17000630 RID: 1584
		// (get) Token: 0x06001E3D RID: 7741 RVA: 0x0009125E File Offset: 0x0008F45E
		// (set) Token: 0x06001E3E RID: 7742 RVA: 0x00091266 File Offset: 0x0008F466
		private bool is_mouse_on { get; set; } = false;

		// Token: 0x06001E3F RID: 7743 RVA: 0x0009126F File Offset: 0x0008F46F
		private void UserButton_MouseLeave(object sender, EventArgs e)
		{
			this.is_mouse_on = false;
			base.Invalidate();
		}

		// Token: 0x06001E40 RID: 7744 RVA: 0x00091281 File Offset: 0x0008F481
		private void UserButton_MouseEnter(object sender, EventArgs e)
		{
			this.is_mouse_on = true;
			base.Invalidate();
		}

		// Token: 0x17000631 RID: 1585
		// (get) Token: 0x06001E41 RID: 7745 RVA: 0x00091293 File Offset: 0x0008F493
		// (set) Token: 0x06001E42 RID: 7746 RVA: 0x0009129B File Offset: 0x0008F49B
		private bool is_left_mouse_down { get; set; } = false;

		// Token: 0x06001E43 RID: 7747 RVA: 0x000912A4 File Offset: 0x0008F4A4
		private void UserButton_MouseUp(object sender, MouseEventArgs e)
		{
			bool flag = e.Button == MouseButtons.Left;
			if (flag)
			{
				this.is_left_mouse_down = false;
				base.Invalidate();
			}
		}

		// Token: 0x06001E44 RID: 7748 RVA: 0x000912D4 File Offset: 0x0008F4D4
		private void UserButton_MouseDown(object sender, MouseEventArgs e)
		{
			bool flag = e.Button == MouseButtons.Left;
			if (flag)
			{
				this.is_left_mouse_down = true;
				base.Invalidate();
			}
		}

		/// <summary>
		/// 触发一次点击的事件
		/// </summary>
		// Token: 0x06001E45 RID: 7749 RVA: 0x00091304 File Offset: 0x0008F504
		public void PerformClick()
		{
			this.OnClick(new EventArgs());
		}

		/// <summary>
		/// 重绘数据区
		/// </summary>
		/// <param name="e"></param>
		// Token: 0x06001E46 RID: 7750 RVA: 0x00091314 File Offset: 0x0008F514
		protected override void OnPaint(PaintEventArgs e)
		{
			bool flag = !Authorization.nzugaydgwadawdibbas();
			if (!flag)
			{
				e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
				e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
				GraphicsPath graphicsPath = new GraphicsPath();
				graphicsPath.AddLine(this.RoundCorner, 0, base.Width - this.RoundCorner - 1, 0);
				graphicsPath.AddArc(base.Width - this.RoundCorner * 2 - 1, 0, this.RoundCorner * 2, this.RoundCorner * 2, 270f, 90f);
				graphicsPath.AddLine(base.Width - 1, this.RoundCorner, base.Width - 1, base.Height - this.RoundCorner - 1);
				graphicsPath.AddArc(base.Width - this.RoundCorner * 2 - 1, base.Height - this.RoundCorner * 2 - 1, this.RoundCorner * 2, this.RoundCorner * 2, 0f, 90f);
				graphicsPath.AddLine(base.Width - this.RoundCorner - 1, base.Height - 1, this.RoundCorner, base.Height - 1);
				graphicsPath.AddArc(0, base.Height - this.RoundCorner * 2 - 1, this.RoundCorner * 2, this.RoundCorner * 2, 90f, 90f);
				graphicsPath.AddLine(0, base.Height - this.RoundCorner - 1, 0, this.RoundCorner);
				graphicsPath.AddArc(0, 0, this.RoundCorner * 2, this.RoundCorner * 2, 180f, 90f);
				Rectangle r = new Rectangle(base.ClientRectangle.X, base.ClientRectangle.Y, base.ClientRectangle.Width, base.ClientRectangle.Height);
				bool enabled = base.Enabled;
				Brush brush;
				Brush brush2;
				if (enabled)
				{
					brush = new SolidBrush(this.TextColor);
					bool selected = this.Selected;
					if (selected)
					{
						brush2 = new SolidBrush(Color.DodgerBlue);
					}
					else
					{
						bool is_mouse_on = this.is_mouse_on;
						if (is_mouse_on)
						{
							brush2 = new SolidBrush(this.ActiveColor);
						}
						else
						{
							brush2 = new SolidBrush(this.OriginalColor);
						}
					}
					bool is_left_mouse_down = this.is_left_mouse_down;
					if (is_left_mouse_down)
					{
						r.Offset(1, 1);
					}
				}
				else
				{
					brush = new SolidBrush(Color.Gray);
					brush2 = new SolidBrush(this.EnableColor);
				}
				e.Graphics.FillPath(brush2, graphicsPath);
				Pen pen = new Pen(Color.FromArgb(170, 170, 170));
				bool borderVisiable = this.BorderVisiable;
				if (borderVisiable)
				{
					e.Graphics.DrawPath(pen, graphicsPath);
				}
				e.Graphics.DrawString(this.UIText, this.Font, brush, r, this.sf);
				brush.Dispose();
				brush2.Dispose();
				pen.Dispose();
				graphicsPath.Dispose();
			}
		}

		// Token: 0x06001E47 RID: 7751 RVA: 0x00091618 File Offset: 0x0008F818
		private void UserButton_KeyDown(object sender, KeyEventArgs e)
		{
			bool flag = e.KeyCode == Keys.Return;
			if (flag)
			{
				this.OnClick(new EventArgs());
			}
		}

		/// <summary>
		/// 点击按钮的触发事件
		/// </summary>
		/// <param name="e"></param>
		// Token: 0x06001E48 RID: 7752 RVA: 0x00091644 File Offset: 0x0008F844
		protected override void OnClick(EventArgs e)
		{
			bool enabled = base.Enabled;
			if (enabled)
			{
				base.OnClick(e);
			}
		}

		/// <summary>
		/// 点击的时候触发事件
		/// </summary>
		/// <param name="e"></param>
		// Token: 0x06001E49 RID: 7753 RVA: 0x00091668 File Offset: 0x0008F868
		protected override void OnMouseClick(MouseEventArgs e)
		{
			bool enabled = base.Enabled;
			if (enabled)
			{
				base.OnMouseClick(e);
			}
		}

		/// <summary> 
		/// 清理所有正在使用的资源。
		/// </summary>
		/// <param name="disposing">如果应释放托管资源，为 true；否则为 false。</param>
		// Token: 0x06001E4A RID: 7754 RVA: 0x0009168C File Offset: 0x0008F88C
		protected override void Dispose(bool disposing)
		{
			bool flag = disposing && this.components != null;
			if (flag)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}

		/// <summary> 
		/// 设计器支持所需的方法 - 不要修改
		/// 使用代码编辑器修改此方法的内容。
		/// </summary>
		// Token: 0x06001E4B RID: 7755 RVA: 0x000916C4 File Offset: 0x0008F8C4
		private void InitializeComponent()
		{
			base.SuspendLayout();
			base.AutoScaleDimensions = new SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = Color.Transparent;
			base.Name = "UserButton";
			base.Size = new Size(78, 25);
			base.Load += this.UserButton_Load;
			base.KeyDown += this.UserButton_KeyDown;
			base.ResumeLayout(false);
		}

		// Token: 0x0400069E RID: 1694
		private int RoundCorner = 3;

		// Token: 0x0400069F RID: 1695
		private StringFormat sf = null;

		// Token: 0x040006A0 RID: 1696
		private string _text = "button";

		// Token: 0x040006A2 RID: 1698
		private bool m_Selected = false;

		// Token: 0x040006A3 RID: 1699
		private Color m_backcor = Color.Lavender;

		// Token: 0x040006A4 RID: 1700
		private Color m_enablecolor = Color.FromArgb(190, 190, 190);

		// Token: 0x040006A5 RID: 1701
		private Color m_active = Color.AliceBlue;

		// Token: 0x040006A6 RID: 1702
		private bool m_BorderVisiable = true;

		/// <summary> 
		/// 必需的设计器变量。
		/// </summary>
		// Token: 0x040006AA RID: 1706
		private IContainer components = null;
	}
}
